package com.hnevc.acountms.dao;

import com.hnevc.acountms.model.Tb_inaccount;

import org.litepal.crud.DataSupport;

import java.util.List;

/**
 * Created by Administrator on 2017/9/27.
 */

public class InaccountDao {
    public void add(Tb_inaccount inaccount){
        inaccount.save();
    }
    public void update(Tb_inaccount inaccount){
        inaccount.save();
    }
    public Tb_inaccount find(int id){
        Tb_inaccount inaccount= DataSupport
                .find(Tb_inaccount.class,(long)id);
        return inaccount;

    }
    public void delete(int... ids){
        for(int i=0;i<ids.length;i++) {
            DataSupport.deleteAll(Tb_inaccount.class, "id=?", ids[i]+"");
        }
    }
    public List<Tb_inaccount> getScrollData(int start, int count){
        List<Tb_inaccount> inaccounts = DataSupport.limit(count)
                .offset(start)
                .find(Tb_inaccount.class);
        return inaccounts;

    }
    public long getCount(){
        int count = DataSupport.count(Tb_inaccount.class);
        return count;
    }
    public int getMaxId(){
        int id = DataSupport.max(Tb_inaccount.class, "_id", int.class);
        return id;

    }
}
